<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>粉丝</title>

		<meta name="viewport" content="initial-scale=1, maximum-scale=1">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<!-- 引入css文件 -->
		<link rel="stylesheet" href="../css/sm.min.css">
		<link rel="stylesheet" href="../css/sm-extend.min.css">
		<link rel="stylesheet" href="../css/iconfont.css">
		<style type="text/css">
			#index {
				margin-top: 0.4rem;
			}
			.infinite-scroll-preloader {
				margin-top: -20px;
			}
			/* 卡片内容加边距 */
			.my-cont{
				padding:.2rem .99rem;
				text-align:center
				
			}
			/* 背景色白色 */
			.page, .page-group{
				background-color: white;
			}
			/* 去掉卡片边距 */
			.card{
				/* margin: 0; */
			}
			.card-content{
				margin: 0.625rem;
			}
			/* 用户字体 */
			.list-block .my-user{
				font-size :0.6rem;
				color:rgb(150,150,150);
			}
			/* 头像圆角 */
			.my-photo img{
				border-radius: 1rem;
			}
			/*商品*/
			.commodity-title{
				font-weight: bold;
				font-size: medium;
			}
			.commodity-price{
				font-weight: bold;
				color: red;
				padding-right: 5rem;
				font-size: medium;
			}
			/* 用户 */
			.user-name{
				font-size :0.6rem;
				color:gray;
			}
			.leavemessage{
				font-size :0.6rem;
			}
			.link{
				font-size :0.6875rem;
				font-weight: bold;
			}
			/* 跳转连接颜色 */
			a{
				color: inherit;
			}
			a:active{
				color: inherit;
			}
			/* 卡片主内容左右边距 */
			.my-data{
				padding-right: 7rem;
			}
		</style>
	</head>
	<body>
		<!-- page 容器 -->
		<div class="page" id="app">
			<!-- 标题栏 -->
			<header class="bar bar-nav" style="background-color: white;"> 
				<a class="icon icon-left button button-link pull-left" @click="goBack" style="color: black;"></a>
				<h1 class="title" style="color: #000000;">她的粉丝</h1>
			</header>
			
			<!-- 页面内容 -->
			<div class="content">
				<!-- 主内容 -->
				<div class="list-block">
					<div class="card list-container" v-for="fan in fans">
						<div class="list-block media-list inset ">
							<ul>
							  <li>
								<a @click="(fan.user.id==loginUser.id)?goLoginUser():goUser(fan.user.id)" class="item-link item-content">
								  <div class="item-media">
									  <img :src="imgSrc(fan.user.photo)" style='width: 2.2rem;'>
									</div>
								  <div class="item-inner">
									<div class="item-title-row">
									  <div class="item-subtitle">{{fan.user.nickname}}</div>
									</div>
									<div class="user-name">{{fan.user.intro}}</div>
								  </div>
								</a>
							  </li>
							</ul>
						</div>
					</div>
				</div>
			</div>
		</div>
		<script src='../js/jquery-3.2.1.min.js'></script>
		<script src='../js/sm.js'></script>
		<script src='../js/sm-extend.js'></script>
		<script src='../js/vue.js'></script>
		<script src='../js/axios.min.js'></script>
		<script src="../js/config.js"></script>
		
		<script type="text/javascript">
			//获取url中的参数
			function getUrlParam(name) {
			var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
			var r = window.location.search.substr(1).match(reg); //匹配目标参数
			if (r != null) return unescape(r[2]); return null; //返回参数值
			 }
		</script>
		
		<script>
			//获取URL参数
			var userid = getUrlParam('userid');
			
			//VUE
			var app = new Vue({
				el:"#app",
				data:{
					user:null,
					loginUser:null,
					fans:[]
				},
				created() {
					//初始加载用户
					this.inituser();
					//初始加载所有粉丝
					this.initfans();
					//初始化加载登录用户
					this.initloginuser();
				},
				// 方法
				methods:{
					inituser: function() {
						axios.get(serviceIP+"/market/inituser?userid=" + userid,{
							headers:{"token":token,"refreshtoken":refreshtoken}
						}).then(result => {
							this.user = result.data.data;
						});
					},
					initfans: function() {
						axios.get(serviceIP+"/market/inituserfans?userid=" + userid,{
							headers:{"token":token,"refreshtoken":refreshtoken}
						}).then(result => {
							this.fans = result.data.data;
							//console.log(result.data.data);
						});
					},
					initloginuser: function() {
						axios.get(serviceIP+"/market/initloginuser",{
							headers:{"token":token,"refreshtoken":refreshtoken}
						}).then(result => {
							this.loginUser = result.data.data;
						});
					},
					
					//跳转上层打开页面
					goBack:function(){
						window.history.go(-1)
					},
					//图片映射
					imgSrc: function(src) {
						return src;
					},
					//跳转到用户页面
					goUser:function(id){
						window.location="market-user.html?userid="+id
					},
					//如果是我自己的商品点击跳转我的个人主页
					goLoginUser:function(){
						window.location="market-mypage.html?loginuserid="+this.loginUser.id
					},
				},
			});
		</script>

		<script>
			$.init();
		</script>
	</body>

</html>
